package com.rd.student.jiaji.class3.zhangshixuan.Day0731;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        for (int i = 0; i < 50; i++) {
            list.add(i);
        }
        int len = list.size();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要随机的个数:");
        int n = sc.nextInt();
        HashSet<Integer> set = new HashSet<>();
        while (set.size() < n) {
            int random = (int) (Math.random() * len);
            System.out.println("随机的结果:" + list.get(random));
            set.add((Integer) list.get(random));
        }
        System.out.println("最终的结果:");
        System.out.println(set);
    }
}
